import NativeClient from "../../../frame/native/NativeClient";
import { $planet_AudioManager_poof$ } from "../manager/audio-manager";
import { $planet_NCAPIStructMap_poof$, $planet_NCAPIURI_poof$, $planet_NCRequestParam_poof$ } from "./api.config.client";

export class $planet_ClientAPI_poof$ {
	private static $planet_send_poof$<A extends $planet_NCAPIURI_poof$>(api: A, data?: $planet_NCAPIStructMap_poof$[A]['$planet_request_poof$']['$planet_data_poof$'], ccdata?: any){
		return NativeClient.sendMessage<$planet_NCAPIStructMap_poof$[A]>(api, data, ccdata);
	}

	public static async $planet_DeviceID_poof$(){
		return $planet_ClientAPI_poof$.$planet_send_poof$($planet_NCAPIURI_poof$.$planet_DeviceID_poof$)
		.$planet_response_poof$
		.then(res=>'Android::'+res.$planet_data_poof$.$planet_device_id_poof$);
	}

	/** 本地化接口 */
	public static async $planet_Local_poof$(){
		return $planet_ClientAPI_poof$.$planet_send_poof$($planet_NCAPIURI_poof$.$planet_LOCAL_poof$)
		.$planet_response_poof$
		.then(res=>res.$planet_data_poof$);
	}

	/** 广告请求 */
	public static async $planet_AD_poof$(type: $planet_NCRequestParam_poof$<$planet_NCAPIURI_poof$.$planet_AD_poof$, '$planet_type_poof$'>){
		$planet_ClientAPI_poof$.$planet_Float_poof$();
		let struct = $planet_ClientAPI_poof$.$planet_send_poof$($planet_NCAPIURI_poof$.$planet_AD_poof$, {$planet_type_poof$: type}, abd.$planet_string_poof$.$planet_random_poof$(5, 36));
		$planet_AudioManager_poof$.$planet_ins_poof$.$planet_pauseBgm_poof$();
		let status = (await struct.$planet_response_poof$).$planet_data_poof$.$planet_status_poof$;
		$planet_AudioManager_poof$.$planet_ins_poof$.$planet_playBGM_poof$();
		return status=='ad-over';
	}

	/**
	 * 在浏览器中打开一个指定的链接
	 * @param url
	 * @returns
	 */
	public static async $planet_Link_poof$(url: $planet_NCRequestParam_poof$<$planet_NCAPIURI_poof$.$planet_LINK_poof$, '$planet_url_poof$'>){
		return $planet_ClientAPI_poof$.$planet_send_poof$($planet_NCAPIURI_poof$.$planet_LINK_poof$, {$planet_url_poof$: url});
	}

	public static async $planet_Fruit_poof$(type: $planet_NCRequestParam_poof$<$planet_NCAPIURI_poof$.$planet_Fruit_poof$, '$planet_type_poof$'>){
		return $planet_ClientAPI_poof$.$planet_send_poof$($planet_NCAPIURI_poof$.$planet_Fruit_poof$, {$planet_type_poof$: type});
	}

	public static async $planet_Float_poof$(){
		return $planet_ClientAPI_poof$.$planet_send_poof$($planet_NCAPIURI_poof$.$planet_Float_poof$);
	}

	public static async $planet_GameType_poof$(){
		return $planet_ClientAPI_poof$
		.$planet_send_poof$($planet_NCAPIURI_poof$.$planet_GameType_poof$)
		.$planet_response_poof$
		.then(res=>res.$planet_data_poof$.$planet_type_poof$);
	}
}
